﻿@model ListViewModel<CommonSearchValues, IQueryable<QizSmsSession>>

@{
    ViewBag.Title = "短信随访查询";
    ViewBag.Back = "/";    
}

<div style="background: rgb(246,246,246);">
    <a href="#" id="btn_search" style="display: inline-block;"
        class="ui-btn ui-icon-search ui-btn-icon-left" data-role="button"
        data_corners="false" data_icon="search" data_shadow="false"
        data_wrapperels="span">查询</a>
</div>
<div class="clear"></div>
<div class="searchbar">
    @using (Html.BeginForm())
    {        
        <fieldset>
            <legend></legend>
            <label>随访单名称</label>
            @Html.DropDownListFor(m => m.SearchFrom.V1, new SelectList(ViewBag.Subjects, "ID", "Title", Model.SearchFrom.V1), "全部")
            <label>检查时间</label><input name="SearchFrom.V3" id="SearchFrom_V3" type="date" 
                value="@(Model.SearchFrom != null && !String.IsNullOrEmpty(Model.SearchFrom.V3) ? Model.SearchFrom.V3 : "")" />
            <label>至</label><input name="SearchTo.V2" id="SearchTo_V2" type="date" 
                value="@(Model.SearchTo != null && !String.IsNullOrEmpty(Model.SearchTo.V3) ? Model.SearchTo.V3 : "")" />
            <input type="hidden" name="PageIdx" value="1" />
            <p>
                <input type="submit" value="确定" />
            </p>
        </fieldset>
    }
</div>
@if (Model == null || Model.ItemCount == 0)
{
    <p>没有查询到短信随访记录！</p>
}
else
{
    var queryString = Request.QueryString.ToString();
    
    <ul id="qsmslist">
        @foreach (var qsms in Model.Data)
        {
            string currentUrl = Request.Path.Split('#')[0];
            currentUrl += "#qsms_" + qsms.ID;
            <li class="@(qsms.SessionAutoEvalution != "异常" ? "border-green" : "border-red")">
                <a name="qsms_@qsms.ID" href="@Url.Action("QizSmsSessionView", new { id = qsms.ID, back = currentUrl })">                    
                    <h3>
                        @qsms.QizSmsSubjectMonthIdx.QizSmsSubject.Title
                        @if (qsms.UnRead)
                        {
                        <span style="color:#ec6100;font-size:0.8em;">[未读]</span>
                        }
                    </h3>
                    <h4>检查结果：
                        @if (qsms.SessionAutoEvalution == "异常")
                        {
                            <span class="validation-summary-errors">异常</span>
                        }
                        else
                        {
                            <span>正常</span>
                        }
                    </h4>
                    <p>检查时间：@qsms.Timemark.ToString("yyyy-MM-dd")</p>
                    <p>填报时间：@qsms.CreationTime.ToString("yyyy-MM-dd")</p>
                    @if (qsms.Recuper.DeHospDay != DateTime.MinValue)
                    {
                        <p>出院时间：@qsms.Recuper.DeHospDay.ToString("yyyy-MM-dd")</p>
                    }
                </a>
            </li>
        }
    </ul>
        using (Html.BeginForm("QizSmsSessionList", "Home", FormMethod.Post, new { id = "pageform" }))
        {
    <input type="hidden" id="pageIndex" name="PageIdx" value="@Model.PageIdx" />
    <input type="hidden" id="pageCount" name="PageCount" value="@Model.PageCount" />
    <input name="SearchFrom.V1" id="searchFrom_V1" type="hidden"
               value="@(Model.SearchFrom != null && !String.IsNullOrEmpty(Model.SearchFrom.V1) ? Model.SearchFrom.V1 : "")" />
    <input name="SearchFrom.V3" id="searchFrom_V3" type="hidden" 
               value="@(Model.SearchFrom != null && !String.IsNullOrEmpty(Model.SearchFrom.V3) ? Model.SearchFrom.V3 : "")" />
    <input name="SearchTo.V3" id="searchTo_V3" type="hidden" 
               value="@(Model.SearchTo != null && !String.IsNullOrEmpty(Model.SearchTo.V3) ? Model.SearchTo.V3 : "")" />
            if (Model.PageCount > 1)
            {
    <div class="pagebar">
        @if (Model.PageIdx > 1)
        {
            <a href="javascript:void(0);" class="btn_back" title="上一页" onclick="back();"></a>
        }
        else
        {
            <span class="btn_back"></span>   
        }
        @if (Model.PageIdx < Model.PageCount)
        {
            <a href="javascript:void(0);" class="btn_next" title="下一页" onclick="next();"></a>
        }
        else
        {
            <span class="btn_next"></span>   
        }
    </div>
            }
        }
}

@section Scripts{
    <style type="text/css">
        .searchbar {
            display: none;
            background: rgb(249,249,249);
            width: 100%;
            clear: right;
        }

            .searchbar fieldset {
                padding: 1em;
            }

                .searchbar fieldset legend {
                    display: none;
                }

                .searchbar fieldset label {
                    font-weight: bold;
                }

        .ui-btn {
            margin: 0.2em;
        }

        #qsmslist {
            margin: 1em 0 1em 0;
            padding: 0 0 0 1px;
            list-style: none;
        }

            #qsmslist > li {
                margin: 1em 0;
                padding: 0 0 3px 0.8em;
                font-size: 1em;
                background: #eee;
            }

        .border-green {
            border-left: #a7d30f 5px solid;
        }

        .border-red {
            border-left: #e93854 5px solid;
        }

        #qsmslist > li a {
            text-decoration: none;
            color: #000;
        }

        #qsmslist > li h3, #qsmslist > li h4, #qsmslist > li p {
            margin: 0;
        }

        #qsmslist > li h3, #qsmslist > li h4 {
            font-weight: bold;
        }

        #qsmslist > li h3 {
            line-height: 1.8em;
            /*margin-bottom:0.1em;*/
        }

        #qsmslist > li h4 {
            /*line-height:1.6em;*/
            margin-bottom: 0.2em;
        }

        #qsmslist > li p {
            line-height: 1.2em;
            font-size: 0.8em;
        }

        #qsmslist > li.border-red:hover {
            background: #e93854;
        }

        #qsmslist > li.border-green:hover {
            background: #a7d30f;
        }

            #qsmslist > li.border-red:hover a, #qsmslist > li.border-red:hover .validation-summary-errors, #qsmslist > li.border-green:hover a {
                color: #fff;
            }
        /*.ui-content .ui-listview {
            margin: 0 0 1em 0;
        }

        .ui-listview > li {
            padding: 0.5em;
            margin: 0;
        }*/

        /*.ui-listview > li a.ui-btn {
            padding: 0;
            margin:0 0 0 0em;            
            background:none !important;
            border:none;
        }
            .ui-listview > li.border-red a.ui-btn:hover {
                background:#e93854;
            }
            .ui-listview > li.border-green a.ui-btn:hover {
                background:#a7d30f;
            }*/
        /*.ui-listview > li table {
            width: 100%;
            border-collapse: collapse;
        }

            .ui-listview > li table th, td {
                border: #fff 1px solid;
                min-height: 24px;
                word-wrap: break-word;
                word-break: break-all;
                padding: 5px;
                font-size: 0.8em;
                color: #000;
                text-decoration: none;
            }

            .ui-listview > li table th {
                background: #ccc;
                text-align: center;
            }

            .ui-listview > li table td {
                text-align: left;
            }*/

        .pagebar {
            height: 50px;
            line-height: 50px;
            background: #333;
            padding-left: 50%;
            margin-top: -1em;
        }

            .pagebar a, .pagebar span {
                width: 32px;
                height: 32px;
                line-height: 32px;
                display: block;
                float: left;
                margin: 9px 20px 0px 0px;
            }

        a.btn_back {
            background: url(/Content/images/icon-back-32-fff.png) no-repeat;
        }

        span.btn_back {
            background: url(/Content/images/icon-back-32-999.png) no-repeat;
        }

        a.btn_back, span.btn_back {
            margin-left: -52px;
        }

        a.btn_next {
            background: url(/Content/images/icon-next-32-fff.png) no-repeat;
        }

        span.btn_next {
            background: url(/Content/images/icon-next-32-999.png) no-repeat;
        }
    </style>
    <script type="text/javascript">
        function back() {
            var pageIndex = $('#pageIndex').val();
            pageIndex--;
            $('#pageIndex').val(pageIndex);
            $('#pageform').submit();
        };
        function next() {
            var pageIndex = $('#pageIndex').val();
            pageIndex++;
            $('#pageIndex').val(pageIndex);
            $('#pageform').submit();
        };
        $(function () {
            $('#btn_search').click(function () {
                if ($('.searchbar').is(':hidden')) {
                    $('.searchbar').show();
                } else {
                    $('.searchbar').hide();
                }
            });
            //var li = $('#qsmslist li:first').clone(true);
            //li.removeClass('border-red').addClass('border-green');
            //li.find('.validation-summary-errors').text('正常').removeClass('validation-summary-errors');
            //$('#qsmslist').append(li);
            //var li2 = $('#qsmslist li:first').clone(true);
            //li2.removeClass('border-red').addClass('border-green');
            //li2.find('.validation-summary-errors').text('正常').removeClass('validation-summary-errors');
            //$('#qsmslist').append(li2);
            //var li3 = $('#qsmslist li:first').clone(true);
            //$('#qsmslist').append(li3);
        });
    </script>
}